The program fails to display `cout` when it is run
Posted
by
Jeff - FL
on Stack Overflow
See other posts from Stack Overflow
or by Jeff - FL
Published on 2011-01-15T18:35:00Z
Indexed on
2011/01/15
18:53 UTC
Read the original article
Hit count: 208
visual-c++
Hello,
I justed started a C++ course & I wrote, compiled, debugged & ran my first program:
// This program calculates how much a little league team spent last year to purchase new baseballs.
#include <iostream>
using namespace std;
int baseballs;
int cost;
int total;
int main()
{
baseballs, cost, total;
// Get the number of baseballs were purchased.
cout << "How many baseballs were purchased? ";
cin >> baseballs;
// Get the cost of baseballs purchased.
cout << "What was the cost of each baseball purchased? ";
cin >> cost;
// Calculate the total.
total = baseballs * cost;
// Display the total.
cout << "The total amount spent $" << total << endl;
return 0;
}
The only probelm that I encountered was that when I ran the program it failed to display the total amount spent (cout). Could someone please explain why?
Thanks
Jeff H - Sarasota, FL
© Stack Overflow or respective owner